var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    telephone:'',
    checktxt:'',
    isTap:1,
    isShow:false,
    timer:'',//定时器名字
    countDownNum:'60'
 },
  countDown:function(){
    let that=this
    var countDownNum=that.data.countDownNum

    that.setData({
      isShow:true,
      
      isTap:2,
      timer:setInterval(function(){
         countDownNum--
         that.setData({
          countDownNum:countDownNum
         })
         if(countDownNum==0){
           clearInterval(that.data.timer)
           that.setData({
             countDownNum: 60,
             isShow:false,
             isTap:1
           })
         }
      },1200)
    })
  },
   getValue:function(res){
     console.log(res.detail.value)
     this.setData({
       telephone:res.detail.value
     })
   },
   getYanzhen2:function(e){
      wx.showToast({
        title: '已经发送了验证码，请耐心等待哦~~~~',
        icon:'none'
      })
   },
   getYanzhen1:function(e){
     this.countDown()
     wx.showModal({
       title: '',
       content: '每人每天只能请求四次验证码哦~~~',
     })
     var tel=this.data.telephone
    // app.qingqiu('telephone/sms',{telephone:tel},'POST',this.callBackFun)
    var that=this
    wx.request({
      url: app.globalData.baseUrl+'telephone/sms',
      method:'POST',
      header:{
        'cookie':'JSESSIONID='+wx.getStorageSync('sessionID'),
        'content-type': 'application/x-www-form-urlencoded'
      },
      
      data:{
        telephone: tel
      },
      success:function(res){
        console.log(res)
        wx.setStorage({
          key: 'checktxt',
          data: e.detail.value,
        })
      }
    })
   },
   callBackFun:function(res){
      console.log(res)
     wx.setStorage({
       key: 'checktxt',
       data: event.detail.value,
     })
   },
   getCheckTxt:function(event){
    wx.setStorage({
      key: 'checktxt',
      data: event.detail.value,
    })
   },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  submit:function(event){
    wx.navigateBack({
      
    })
    wx.setStorage({
      key: 'telephone',
      data: this.data.telephone,
    })
   
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})